var express = require('express');
var router = express.Router();
var admin = require('../controller/admin.js')
/**
 * @swagger
 * definitions:
 *  userinfo:
 *     properties:
 *       username:
 *         type: string
 *         description: 用户名
 *       password:
 *         type: string
 *         description: 密码
 *  useritem:
 *     properties:
 *       id:
 *         type: integer
 *         description: 用户id
 *       username:
 *         type: string
 *         description: 用户名
 *         example: admin
 *       createTime:
 *         type:integer
 *         description:创建时间
 *       type:
 *         type:integer
 *         description:0为超级管理员 1为普通用户
 *  addInfo:
 *     properties:
 *       username:
 *         type:string
 *         description:用户名
 *       password:
 *         type:string
 *         description:密码
 *       confirm:
 *         type:string
 *         description:确认密码
 *       type:
 *         type:integer
 *         description:用户类型
 * /admin/login:
 *   post:
*     tags:
*       - 后台管理系统
*     description: 登录接口
*     produces:
*       - application/json
*     parameters:
*       - name: userinfo
*         description: userinfo object
*         in: body
*         required: true
*         schema:
*           $ref: '#/definitions/userinfo'
*     responses:
*       200:
*         description: 登陆成功
*         schema:
*           $ref: '#/definitions/userinfo'
* /admin/user:
*   get:
*     tags:
*       - 后台管理系统
*     description: 返回所有用户列表
*     produces:
*       - application/json
*     responses:
*       200:
*         description: 涵盖所有文章列表信息的数组
*         schema:
*           $ref: '#/definitions/useritem'
*/
/**
 * @swagger
 * /admin/user:
 *   post:
 *     tags:
 *       - 后台管理系统
 *     description: 添加用户
 *     produces:
 *       - application/json
 *     parameters:
 *       - name: addInfo
 *         description: 添加用户信息
 *         in: body
 *         required: true
 *         schema:
 *           $ref: '#/definitions/addInfo'
 *     responses:
 *       200:
 */
/**
 * @swagger
 * /admin/user:
 *   delete:
 *     tags:
 *       - 后台管理系统
 *     description: 删除用户
 *     produces:
 *       - application/json
 *     parameters:
 *       - name: userid
 *         description: 删除用户
 *         in: query
 *         required: true
 *     responses:
 *       200:
 */

/**
 * @swagger
* /admin/article:
*   get:
*     tags:
*       - 后台管理系统
*     description: 返回所有文章列表
*     produces:
*       - application/json
*     responses:
*       200:
*         description: 涵盖所有文章列表信息的数组
*/
/**
 * @swagger
 * /admin/article:
 *   post:
 *     tags:
 *       - 后台管理系统
 *     description: 添加文章
 *     produces:
 *       - application/json
 *     parameters:
 *       - name: addInfo
 *         description: 添加文章
 *         in: body
 *         required: true
 *         schema:
 *           $ref: '#/definitions/addInfo'
 *     responses:
 *       200:
 */
/**
 * @swagger
* /admin/articletype:
*   get:
*     tags:
*       - 后台管理系统
*     description: 文章类别
*     produces:
*       - application/json
*     responses:
*       200:
*         description: 涵盖所有文章列表信息的数组
*/
/**
 * @swagger
 * /admin/article:
 *   delete:
 *     tags:
 *       - 后台管理系统
 *     description: 删除文章
 *     produces:
 *       - application/json
 *     parameters:
 *       - name: userid
 *         description: 删除文章
 *         in: query
 *         required: true
 *     responses:
 *       200:
 */
router.post('/login', admin.login);
router.get('/user', admin.getUserlist);
router.post('/user', admin.addUser);
router.delete('/user', admin.delUser);
router.get('/role', admin.getRole);
router.get('/article', admin.getArticlelist);
router.post('/article', admin.addArticle);
router.get('/articletype', admin.getArticleType);
router.delete('/article', admin.delArticle);
router.get('/articleById', admin.getArticleconById);
router.post('/articletype', admin.addType);

module.exports = router;
